
package ai;

import java.awt.Robot;

import util.ThreadUtil;

public class MouseOperator
{
	public static void clickOn(int i, int j) throws Throwable
	{
		Robot robot = new Robot();
		robot.mouseMove(i, j);
		robot.mousePress(16);
		Thread.sleep(300);
		robot.mouseRelease(16);
		Thread.sleep(100);
		robot.mouseMove(10, 10);
		Thread.sleep(100);
	}
	
	public static void clickOn(int i, int j, int [] equalWidthPos, int [] equalHeightPos)
	{
		int m = (equalWidthPos[i] + equalWidthPos[i + 1]) / 2;
		int n = (equalHeightPos[j] + equalHeightPos[j + 1]) / 2;
//		System.out.println("点击(" + i + ":" + j + ")  位于：(" + m + ":" + n + ")");
		try
		{
			MouseOperator.clickOn(m, n);
		}catch(Throwable e)
		{
			e.printStackTrace();
		}
	}
	
	public static void clickOn(int [][] action, int [] comboNum, int [] equalWidthPos, int [] equalHeightPos)
	{
		for(int i = 0; i < action.length; i++)
		{
			MouseOperator.clickOn(action[i][1], action[i][0], equalWidthPos, equalHeightPos);
			ThreadUtil.sleep(comboNum[i] * 750);
		}
	}
}
